<template>
  <div class="container">
    <!-- 面包屑导航 -->
    <div class="breadcrumb">
      <el-breadcrumb separator="">
        <el-breadcrumb-item>
          <div class="div1">客户管理</div>
        </el-breadcrumb-item>
        <el-breadcrumb-item>
          <div class="div2">健驰客户导入</div>
        </el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <!-- 面包屑导航 -->
    <div class="nav">
      <el-tabs v-model="activeName" @tab-click="handleClick">
        <el-tab-pane
          label="未分配客户"
          name="2"
          v-if="parArray.indexOf('wfpCode') != -1"
        >
          <span slot="label">
            <el-badge
              v-if="
                $store.getters.orderCount &&
                $store.getters.orderCount.wechatUnassignedNum
              "
              :value="$store.getters.orderCount.wechatUnassignedNum"
            >
              未分配客户
            </el-badge>
            <span v-else>未分配客户</span>
          </span>
        </el-tab-pane>
        <el-tab-pane
          label="分配失败"
          name="3"
          v-if="parArray.indexOf('fpsbCode') != -1"
        ></el-tab-pane>
        <el-tab-pane label="分配成功" name="1"></el-tab-pane>
      </el-tabs>
    </div>
    <el-collapse-transition>
      <div class="inquiry" v-show="!show3">
        <div class="header">
          <span>查询数据</span>
          <p @click="show3 = true">收起</p>
        </div>
        <el-form
          :inline="true"
          ref="form"
          :model="queryForm"
          label-width=""
          size="mini"
        >
          <el-form-item label="资源信息">
            <el-input
              placeholder="请输入客户手机号码/姓名"
              v-model="queryForm.info"
            ></el-input>
          </el-form-item>

          <el-form-item v-if="salesAuthorityId != '1'" label="平台名称">
            <el-select
              v-model="queryForm.sourceFrom"
              placeholder="平台名称"
              clearable
              default-first-option
              filterable
            >
              <el-option
                v-for="items in channeSel"
                :key="items.dictId"
                v-if="items.dictId != 'comm'"
                :label="items.dictName"
                :value="items.dictName"
              ></el-option>
            </el-select>
          </el-form-item>

          <div class="selectDate">
            <span>资源时间</span>
            <div class="picker">
              <el-date-picker
                v-model="date"
                type="daterange"
                unlink-panels
                range-separator="至"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
                format="yyyy- MM- dd"
                value-format="yyyy-MM-dd"
                @input="immediUpdate"
              >
              </el-date-picker>
            </div>
          </div>

          <div class="selectDate" v-if="activeName !== '2'">
            <span>分配时间</span>
            <div class="picker">
              <el-date-picker
                v-model="assigedate"
                type="daterange"
                unlink-panels
                range-separator="至"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
                format="yyyy- MM- dd"
                value-format="yyyy-MM-dd"
              >
              </el-date-picker>
              <!-- @input="immediUpdate" -->
            </div>
          </div>

          <el-form-item label="客服">
            <el-select
              clearable
              v-model="queryForm.assignorId"
              placeholder="选择客服"
              filterable
              default-first-option
            >
              <el-option
                v-for="items in customer"
                :key="items.id"
                :label="items.reallyName"
                :value="items.id"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="部门选择">
            <el-cascader
              v-model="queryForm.orgName"
              :options="options"
              :props="{
                checkStrictly: true,
                label: 'orgName',
                value: 'orgCode',
                children: 'children',
              }"
              clearable
              filterable
            ></el-cascader>
          </el-form-item>

          <el-checkbox v-model="queryForm.addedWx">添加微信</el-checkbox>
          <el-checkbox style="margin-right: 10px" v-model="queryForm.dealDone"
            >已开单</el-checkbox
          >

          <el-form-item>
            <el-button type="primary" @click="searchEvent()">搜索</el-button>
            <!-- v-on:keyup.enter="searchEvent" -->
            <el-button plain @click="reset" :loading="loading">重置</el-button>
          </el-form-item>
        </el-form>
      </div>
    </el-collapse-transition>
    <div class="btn">
      <div>
        <el-select
          v-show="
            activeName == '2' && parArray.indexOf('oneKeyImportToWs') != -1
          "
          v-model="guideId"
          placeholder="导入客户"
          @change="modeGuide"
          clearable
        >
          <el-option
            v-for="item in channel"
            :key="item.dictId"
            :label="item.dictName"
            :value="item.dictId"
          ></el-option>
        </el-select>

        <p
          class="onekey"
          v-show="activeName != '1' && parArray.indexOf('assignmentCode') != -1"
          @click="distribution()"
        >
          <span>批量分配</span>
        </p>

        <p
          class="onekey"
          v-show="parArray.indexOf('jcdcCode') != -1"
          @click="wsexport()"
        >
          <span>导出</span>
        </p>
        <p
          class="onekey"
          v-show="activeName == '1' && parArray.indexOf('jcdcCode') != -1"
          @click="unAssign()"
        >
          <span>取消分配</span>
        </p>

        <p
          class="onekey"
          v-show="activeName != '1' && parArray.indexOf('plfixkfCode') != -1"
          @click="plFixService"
        >
          <span>批改客服</span>
        </p>

        <p
          class="onekey"
          v-show="parArray.indexOf('jcDelectCode') != -1 && activeName != '1'"
          @click="deleteUsers"
        >
          <span>批量删除</span>
        </p>

        <p
          class="onekey"
          v-show="parArray.indexOf('metastasisDepa') != -1 && activeName == '1'"
          @click="metastasis"
        >
          <span>转移部门共享池</span>
        </p>
      </div>
      <el-button
        size="mini"
        type="primary"
        @click="show3 = false"
        v-show="show3"
        >搜索展开</el-button
      >
    </div>

    <div class="table">
      <vxe-table
        ref="table"
        row-id="id"
        :data="tableData.list"
        style="width: 100%"
        align="center"
        @checkbox-all="selectAllEvent"
        @checkbox-change="selectChangeEvent"
      >
        >
        <vxe-table-column type="checkbox" width="40"></vxe-table-column>
        <vxe-table-column
          type="seq"
          title="序号"
          min-width="50"
        ></vxe-table-column>
        <vxe-table-column
          field="batchNumber"
          title="批次"
          min-width="50"
        ></vxe-table-column>
        <vxe-table-column
          field="resourceId"
          title="资源ID"
          min-width="80"
        ></vxe-table-column>

        <vxe-table-column title="资源时间" show-overflow min-width="150">
          <template slot-scope="scope">
            <p v-if="!is_null(scope.row.createdTime)">
              {{ scope.row.createdTime }}
            </p>
            <p v-else>--</p>
          </template>
        </vxe-table-column>

        <vxe-table-column title="客户姓名/电话" min-width="150">
          <template slot-scope="scope">
            <el-popover
              placement="top-start"
              width="400"
              trigger="hover"
              :open-delay="400"
              :close-delay="1000"
              @show="getFeedbackLog(scope.row.id, true)"
            >
              <el-table :data="logs">
                <el-table-column
                  width="130"
                  property="userName"
                  label="客服"
                ></el-table-column>
                <el-table-column
                  width="130"
                  property="context"
                  label="进度"
                ></el-table-column>
                <el-table-column
                  width="140"
                  property="createdTime"
                  label="时间"
                ></el-table-column>
              </el-table>
              <div slot="reference">
                <span
                  :style="{
                    fontWeight:
                      scope.row.feedback && scope.row.feedback != '{}'
                        ? 'bold'
                        : '',
                    color:
                      scope.row.feedback && scope.row.feedback != '{}'
                        ? '#409eff'
                        : '',
                  }"
                  >{{ scope.row.customerName }}
                  {{
                    activeName == "3" ? " / " + scope.row.customerPhone : ""
                  }}</span
                >
                <p class="exisit" v-if="activeName == '3'">
                  {{ scope.row.reasonForFailure }}
                </p>
                <p
                  style="cursor: pointer"
                  :style="{
                    fontWeight:
                      scope.row.feedback && scope.row.feedback != '{}'
                        ? 'bold'
                        : '',
                    color:
                      scope.row.feedback && scope.row.feedback != '{}'
                        ? '#409eff'
                        : '',
                  }"
                  @click="
                    $copyText(scope.row.customerPhone).then(
                      function (e) {
                        $message({
                          type: 'success',
                          message: '成功复制手机号',
                        });
                      },
                      function (e) {
                        $message({
                          type: 'warning',
                          message: '复制失败',
                        });
                      }
                    )
                  "
                >
                  {{ scope.row.customerPhone }}
                </p>
              </div>
            </el-popover>
          </template>
        </vxe-table-column>

        <vxe-table-column title="客户信息" show-overflow min-width="120">
          <template slot-scope="scope">
            <p v-if="!is_null(scope.row.customerMessage)">
              {{ scope.row.customerMessage }}
            </p>
            <p v-else>--</p>
          </template>
        </vxe-table-column>

        <vxe-table-column
          title="渠道"
          show-overflow
          min-width="100"
          v-if="salesAuthorityId != '1'"
        >
          <template slot-scope="scope">
            <span>{{ scope.row.sourceFrom }}</span>
          </template>
        </vxe-table-column>

        <vxe-table-column scope="scope" title="渠道号" min-width="150">
          <template slot-scope="scope">
            <!-- v-if="scope.row.isAddCustomer == 'N'" -->
            <div v-if="activeName == '3'">
              <el-select
                v-model="scope.row.channelId"
                placeholder="选择渠道"
                filterable
                default-first-option
                @change="changeContent(scope.row)"
              >
                <el-option
                  v-for="items in line"
                  :key="items.id"
                  :label="items.name"
                  :value="items.id"
                ></el-option>
              </el-select>
            </div>
            <p v-else>{{ scope.row.channelName }}</p>
          </template>
        </vxe-table-column>

        <vxe-table-column
          title="分配团队"
          prop="assignorTeamName"
          min-width="150"
        ></vxe-table-column>

        <vxe-table-column title="现分配客服" min-width="150">
          <template slot-scope="scope">
            <div v-if="activeName != '1'">
              <el-select
                v-model="scope.row.assignorId"
                placeholder="选择客服"
                filterable
                default-first-option
                @change="changeContent(scope.row)"
              >
                <el-option
                  v-for="items in customer"
                  :key="items.id"
                  :label="items.reallyName"
                  :value="items.id"
                ></el-option>
              </el-select>
            </div>
            <p v-else>
              {{ scope.row.assignorName
              }}{{
                scope.row.customerService
                  ? "->" + scope.row.customerService
                  : ""
              }}
            </p>
          </template>
        </vxe-table-column>

        <vxe-table-column
          title="原分配客服"
          min-width="150"
          v-if="activeName == '1'"
        >
          <template slot-scope="scope">
            <p>
              {{ scope.row.originalAssignorName }}
            </p>
          </template>
        </vxe-table-column>

        <vxe-table-column
          title="分配时间"
          show-overflow
          min-width="150"
          v-if="activeName !== '2'"
        >
          <!-- v-if="activeName == '1'" -->
          <template slot-scope="scope">
            <p v-if="!is_null(scope.row.updatedTime)">
              {{ scope.row.updatedTime }}
            </p>
            <p v-else>--</p>
          </template>
        </vxe-table-column>

        <vxe-table-column title="操作" min-width="200" fixed="right">
          <template slot-scope="scope">
            <!-- 确定是否分配给自己 -->
            <p class="operation" v-if="activeName != 1">
              <el-switch
                v-model="scope.row.switchVal"
                active-color="#409EFF"
                inactive-color="#eee"
              >
              </el-switch>
            </p>

            <p
              class="operation"
              @click="distribution(scope.row, scope.$index)"
              v-if="
                activeName != '1' && parArray.indexOf('assignmentCode') != -1
              "
            >
              分配
            </p>

            <p
              class="operation"
              @click="progressShow(scope.row)"
              v-if="parArray.indexOf('progressCode') != -1 && activeName == '1'"
            >
              跟进
            </p>

            <p
              class="operation"
              @click="tosee(scope.row)"
              v-if="parArray.indexOf('jcckCode') != -1 && activeName == '1'"
            >
              <!-- <img src="../../../assets/see.png" alt="" /> -->
              查看
            </p>
            <!-- </el-tooltip> -->
            <!-- <p @click='delectEvent(scope.row)'>删除</p> -->

            <p
              class="operation"
              v-if="parArray.indexOf('jcckCode') != -1"
              @click="copyInfo(scope.row)"
            >
              复制
            </p>

            <p
              v-if="activeName == '1' && parArray.indexOf('kfxq') != -1"
              class="operation"
              @click="toDetailCustomer(scope.row)"
            >
              客户详情
            </p>

            <p
              class="operation delect"
              v-if="parArray.indexOf('jcDelectCode') != -1 && activeName != '1'"
              @click="delectEvent(scope.row, scope.$index)"
            >
              删除
            </p>
          </template>
        </vxe-table-column>
      </vxe-table>
    </div>
    <!-- 分页end -->
    <div style="height: 40px"></div>
    <div class="page" v-if="tableData.totalNum >= 1">
      <div class="block">
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="currentPage1"
          :page-sizes="[10, 20, 50, 100, 200]"
          :page-size="pageSize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="tableData.totalNum"
          prev-text="上一页"
          next-text="下一页"
        >
        </el-pagination>
      </div>
    </div>
    <!-- @close="progressClose" -->
    <el-dialog
      :visible.sync="progress"
      :append-to-body="true"
      title="跟进情况"
      :before-close="progressClose"
    >
      <p style="margin-bottom: 15px; color: #666" v-if="lastFeedbackTime">
        最近更新：{{ lastFeedbackTime }}
      </p>
      <!-- <el-checkbox-group v-model="progressVal"> -->
      <el-checkbox
        true-label="1"
        false-label="0"
        class="haveTo"
        v-model="checkedForm.checked1"
        label="接通"
        v-if="checkedForm.checked2 == 0"
      ></el-checkbox>
      <el-checkbox
        true-label="1"
        false-label="0"
        class="haveTo"
        v-model="checkedForm.checked2"
        label="无法接通/无人接听/拒接"
        v-if="checkedForm.checked1 == 0"
      ></el-checkbox>
      <el-checkbox
        true-label="1"
        false-label="0"
        v-model="checkedForm.checked3"
        label="接通不是本人"
        class="haveTo"
      ></el-checkbox>

      <el-checkbox
        true-label="1"
        false-label="0"
        v-model="checkedForm.checked13"
        label="空号/停机/暂停服务"
        class="haveTo"
      ></el-checkbox>

      <el-checkbox
        true-label="1"
        false-label="0"
        v-model="checkedForm.checked4"
        label="电话沟通完添加微信"
      ></el-checkbox>
      <el-checkbox
        true-label="1"
        false-label="0"
        v-model="checkedForm.checked5"
        label="直接搜索手机号添加"
      ></el-checkbox>
      <el-checkbox
        true-label="1"
        false-label="0"
        v-model="checkedForm.checked6"
        label="有意向/正常走流程"
      ></el-checkbox>
      <el-checkbox
        true-label="1"
        false-label="0"
        v-model="checkedForm.checked7"
        label="添加完不说话"
      ></el-checkbox>

      <el-checkbox
        true-label="1"
        false-label="0"
        v-model="checkedForm.checked8"
        label="添加完拉黑"
      ></el-checkbox>

      <el-checkbox
        true-label="1"
        false-label="0"
        v-model="checkedForm.checked9"
        label="二十岁以下"
      ></el-checkbox>
      <br>
      <el-checkbox
        true-label="1"
        false-label="0"
        v-model="checkedForm.checked10"
        label="秒杀"
      ></el-checkbox>
      <div class="checkbox">
        <el-input
          type="number"
          v-model="checkedForm.checked11"
          placeholder="请输入秒杀金额"
          size="mini"
        />
        <span>秒杀金额</span>
      </div>
      <!--分割线 -->
      <el-divider></el-divider>
      <div class="checkbox haveTo">
<!--        "1.get_through"接通 "2.block_call"未接通-->
        <span>是否接通</span>
        <el-radio-group v-model="checkedForm.isConnect">
          <el-radio label="get_through">接通</el-radio>
          <el-radio label="block_call">未接通</el-radio>
        </el-radio-group>
      </div>
      <div class="checkbox haveTo" v-if="checkedForm.isConnect == 'block_call'">
        <span>未接通情况</span>
        <el-select
            v-model="checkedForm.connectedNotA"
            placeholder="请选择未接通情况"
            size="mini"
            clearable
            filterable
        >
          <el-option
              v-for="item in dictionaries.block_call"
              :key="item.dictId"
              :label="item.dictName"
              :value="item.dictId"
          >
          </el-option>
        </el-select>

      </div>
      <div class="checkbox haveTo" v-if="checkedForm.isConnect == 'get_through'">
        <span>接通情况</span>
        <el-select
            v-model="checkedForm.connectedNotB"
            placeholder="请选择接通情况"
            size="mini"
            clearable
            filterable
        >
          <el-option
              v-for="item in dictionaries.get_through"
              :key="item.dictId"
              :label="item.dictName"
              :value="item.dictId"
          >
          </el-option>
        </el-select>
      </div>
      <!--分割线 -->
      <el-divider></el-divider>
      <div class="checkbox">
        <span>备注</span>
        <el-input
          type="textarea"
          autosize
          v-model="checkedForm.checked12"
          placeholder="请输入备注"
          size="mini"
        />
      </div>

      <!--分割线 -->
      <el-divider></el-divider>
      <div>
        <template>
          <el-table :data="logs" style="width: 100%" max-height="250">
            <el-table-column prop="userName" label="客服" width="100">
            </el-table-column>
            <el-table-column prop="context" label="进度" width="300"></el-table-column>
            <el-table-column prop="qualityLabelName" label="接听状态" width="100"></el-table-column>
            <el-table-column prop="connectedNotName" label="资源反馈" width="100"></el-table-column>
            <el-table-column prop="createdTime" label="时间"> </el-table-column>
          </el-table>
        </template>
      </div>

      <!-- </el-checkbox-group> -->

      <div slot="footer" class="footer">
        <el-button size="mini" type="primary" @click="progreeSubmit()"
          >确定</el-button
        >
        <el-button size="mini" @click="progress = false">取消</el-button>
      </div>
    </el-dialog>

    <el-dialog
      :visible.sync="leadingInLive"
      :append-to-body="true"
      title="订单导入"
      @close="handleDialogClose"
    >
      <div class="popIn">
        <el-upload
          ref="tops"
          class="upload-demo"
          accept=".doc,.docx,.xls,.xlsx,.csv"
          drag
          action="#"
          :multiple="false"
          :http-request="orderImportLive"
          :limit="1"
        >
          <i class="el-icon-upload"></i>
          <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
        </el-upload>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button
          size="mini"
          type="primary"
          v-if="keyvalue == 'comm'"
          @click="
            leadingInLive = false;
            templateMode();
            guideId = '';
            $refs.tops.clearFiles();
          "
          >确 定</el-button
        >

        <el-button
          size="mini"
          type="primary"
          v-if="keyvalue == 'OPPO'"
          @click="
            leadingInLive = false;
            opopImport();
            guideId = '';
            $refs.tops.clearFiles();
          "
          >确 定</el-button
        >

        <el-button
          size="mini"
          type="primary"
          v-if="keyvalue == 'BaiDu'"
          @click="
            leadingInLive = false;
            baiduImport();
            guideId = '';
            $refs.tops.clearFiles();
          "
          >确 定</el-button
        >
        <!-- 放心购 -->
        <el-button
          size="mini"
          type="primary"
          v-if="keyvalue == 'RestAssured'"
          @click="
            leadingInLive = false;
            safeImport();
            guideId = '';
            $refs.tops.clearFiles();
          "
          >确 定</el-button
        >
        <!-- 凤凰 -->
        <el-button
          size="mini"
          type="primary"
          v-if="keyvalue == 'Phoenix'"
          @click="
            leadingInLive = false;
            phoneixImport();
            guideId = '';
            $refs.tops.clearFiles();
          "
          >确 定</el-button
        >
        <!-- 广点通订单 -->
        <el-button
          size="mini"
          type="primary"
          v-if="keyvalue == 'GuangDianTong'"
          @click="
            leadingInLive = false;
            broadpointImport();
            guideId = '';
            $refs.tops.clearFiles();
          "
          >确 定</el-button
        >
        <!-- UC订单导入 -->
        <el-button
          size="mini"
          type="primary"
          v-if="keyvalue == 'uc'"
          @click="
            leadingInLive = false;
            uCImport();
            guideId = '';
            $refs.tops.clearFiles();
          "
          >确 定</el-button
        >
        <!-- 头条订单 -->
        <el-button
          size="mini"
          type="primary"
          v-if="keyvalue == 'head'"
          @click="
            leadingInLive = false;
            headlinesImport();
            guideId = '';
            $refs.tops.clearFiles();
          "
          >确 定</el-button
        >
        <!-- 爱奇艺订单 -->
        <el-button
          size="mini"
          type="primary"
          v-if="keyvalue == 'aqy'"
          @click="
            leadingInLive = false;
            headlinesAiqiyi();
            guideId = '';
            $refs.tops.clearFiles();
          "
          >确 定</el-button
        >

        <!-- 快手 -->
        <el-button
          size="mini"
          type="primary"
          v-if="keyvalue == 'ks'"
          @click="
            leadingInLive = false;
            kwaiFu();
            $refs.tops.clearFiles();
          "
          >确 定</el-button
        >
        <el-button
          size="mini"
          @click="
            leadingInLive = false;
            guideId = '';
            $refs.tops.clearFiles();
          "
          >取 消</el-button
        >
      </div>
    </el-dialog>

    <!-- 批量修改客服 -->
    <el-dialog
      :visible.sync="kfShow"
      :append-to-body="true"
      title="批量修改分配客服"
      :before-close="serviceClose"
    >
      <el-form>
        <!--  -->
        <el-form-item label="客服">
          <el-select
            filterable
            default-first-option
            v-model="moreService"
            placeholder="请选择分配客服"
            size="small"
            multiple
            class="elselect"
            style="width: 90%"
          >
            <el-option
              v-for="items in customer"
              :key="items.id"
              :label="items.reallyName"
              :value="items.id"
            ></el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <div slot="footer" class="footer">
        <el-button size="mini" type="primary" @click="moreGuideCustomer()"
          >确定</el-button
        >
        <el-button size="mini" @click="kfShow = false">取消</el-button>
      </div>
    </el-dialog>
    <!-- 批量修改客服 -->
  </div>
</template>

<script>
export default {
  data () {
    return {
      guideId: "",
      date: "",
      assigedate: "",
      queryForm: {
        info: "",
        sourceFrom: "",
        assignorId: "",
        orgName: "",
        addedWx: false,
        dealDone: false,
      },
      loading: false,
      currentPage1: 1,
      pageSize: 10,
      tableData: [],
      logs: [],
      fileList: [],
      line: [],
      customer: [],
      allocationList: [],
      limits: "",
      parArray: [],
      height: "500px",
      activeName: "2",
      leadingInLive: false,
      show3: false,
      progress: false,
      progressVal: [], //复选框值
      checkedForm: {
        checked1: 0,
        checked2: 0,
        checked3: 0,
        checked4: 0,
        checked5: 0,
        checked6: 0,
        checked7: 0,
        checked8: 0,
        checked9: 0,
        checked10: 0,
        checked11: 0,
        checked12: "",
        checked13: 0,
        isConnect:"", // 是否接通  "1.get_through"接通 "2.block_call"未接通
        qualityLabel:"", // 质量标签 id
        connectedNotA:"",  // 未接通
        connectedNotB:""  // 已接通
      },
      progressId: "", //列表id
      channel: [],
      channeSel: [],
      keyvalue: "",
      multipleSelection: [],
      salesAuthorityId: "",
      kfShow: false, //批量分配客服判断
      moreService: "", //批量分配客服值
      options: [],
      lastFeedbackTime: "",
      dictionaries: {      // 字典数据
        block_call: [],    // 未接通选项
        get_through: []    // 已接通选项
      },
    };
  },
  created () {
    // 获取字典数据
    for (let type in this.dictionaries) { this.getDictionaries(type) }

    this.department();
    // 权限设定判断
    this.limits = JSON.parse(sessionStorage.getItem("limit"));
    const params = this.limits.buttonTreeDto.filter(
      (item) => item.menuCode === "jcGuideCode"
    );
    params[0].buttonList.forEach((item) => {
      this.parArray.push(item.code);
    });

    if (
      this.parArray.indexOf("wfpCode") == -1 &&
      this.parArray.indexOf("fpsbCode") == -1
    ) {
      this.activeName = "1";
    }

    this.salesAuthorityId = JSON.parse(
      sessionStorage.getItem("salesAuthorityId")
    );

    this.axiosList();
    this.channelAxios();
    this.customerlist();
    this.allocation();
    this.channelSource();
    // 权限设定判断
    // let _this = this;
    // document.onkeydown = function (e) {
    //   let key = window.event.keyCode;
    //   if (key == 13) {
    //     _this.searchEvent();
    //   }
    // };
  },
  activated () {
    this.axiosList();
    this.channelAxios();
    this.customerlist();
    this.allocation();
    this.channelSource();
  },
  methods: {
    // 获取字典数据
    getDictionaries (type) {
      if (type && this.dictionaries[type].length > 0) { return }
      const params = { groupId: type }
      this.$api.dictionaries(params).then((res) => {
        this.dictionaries[type] = res.data
      }).catch((err) => {
        console.log(err)
      })
    },
    //删除
    deleteUsers () {
      this.$msgbox({
        title: "提示",
        message: "确定删除这些数据吗",
        confirmButtonText: "确定",
        cancelButtonText: "取消",
      })
        .then((res) => {
          this.axios
            .post(
              "/order/wsCustomerChannelUser/delete",
              this.multipleSelection.map((i) => i.id)
            )
            .then((res) => {
              //   console.log(res);
              if (res.code == 0) {
                this.$message.success("删除成功");
                // let index = this.tableData.list.findIndex(
                //   (item) => item.id == row.id
                // );
                // this.tableData.list.splice(index, 1);
                this.axiosList();
              } else {
                this.$message.warning(res.message);
              }
            });
        })
        .catch(() => { });
    },

    //转移部门共享池
    metastasis () {
      this.$msgbox({
        title: "提示",
        message: "确定转移这些数据吗",
        confirmButtonText: "确定",
        cancelButtonText: "取消",
      })
        .then((res) => {
          let request = {
            ids: this.multipleSelection.map((i) => i.id),
            publicType: "2",
          };
          this.axios
            .post("/order/wsCustomerChannelUser/metastasis", request)
            .then((res) => {
              //   console.log(res);
              if (res.code == 0) {
                this.$message.success(res.data);
                this.axiosList();
              } else {
                this.$message.warning(res.message);
              }
            });
        })
        .catch(() => { });
    },
    copyInfo (row) {
      // console.log(row);
      let that = this;
      let inline = this.line.find((res) => res.id == row.channelId);
      let info =
        "姓名：" +
        row.customerName +
        "\n 电话：" +
        row.customerPhone +
        "\n 渠道：" +
        inline.name +
        ",资源时间：" +
        /\d{4}-\d{1,2}-\d{1,2}/g.exec(row.createdTime);
      that.$copyText(info).then(
        function (e) {
          that.$message({
            type: "success",
            message: "复制成功",
          });
        },
        function (e) {
          that.$message({
            type: "warning",
            message: "复制失败",
          });
        }
      );
    },
    // 导出
    wsexport () {
      this.axios
        .post("/order/wsCustomerChannelUser/export", {
          ids: this.multipleSelection.map((i) => i.id),
          assignEndTime: this.assigedate
            ? this.assigedate[1] + " 23:59:59"
            : "",
          assignStartTime: this.assigedate
            ? this.assigedate[0] + " 00:00:00"
            : "",
          keyWord: this.queryForm.info,
          sourceFrom: this.queryForm.sourceFrom,
          startTime: this.date ? this.date[0] + " 00:00:00" : "",
          endTime: this.date ? this.date[1] + " 23:59:59" : "",
          assignStatus: this.activeName,
          status: "A",
          assignTeam: this.queryForm.orgName[this.queryForm.orgName.length - 1],
          assignId: this.queryForm.assignorId,
          addedWx: this.queryForm.addedWx,
          dealDone: this.queryForm.dealDone,
        })
        .then((res) => {
          if (res.code == 0) {
            this.downloadlink(res.data);
          } else {
            this.$message.error(res.message);
          }
        });
    },
    progressShow (row) {
      this.progressId = row.id;
      this.lastFeedbackTime = row.lastFeedbackTime;
      this.progress = true;
      let feedback = "";
      if (row.feedback) {
        feedback = JSON.parse(row.feedback);
      }
      this.getFeedbackLog(row.id, false);
      if (feedback) {
        this.checkedForm = {
          checked1: feedback["接通"],
          checked2: feedback["无法接通/无人接听/拒接"],
          checked3: feedback["接通不是本人"],
          checked4: feedback["电话沟通完添加微信"],
          checked5: feedback["直接搜索手机号添加"],
          checked6: feedback["有意向/正常走流程"],
          checked7: feedback["添加完不说话"],
          checked8: feedback["添加完拉黑"],
          checked9: feedback["二十岁以下"],
          checked10: feedback["秒杀"],
          checked11: feedback["秒杀金额"],
          checked12: row.comment,
          checked13: feedback["空号/停机/暂停服务"],
        };
      } else {
        this.checkedForm = {
          checked1: 0,
          checked2: 0,
          checked3: 0,
          checked4: 0,
          checked5: 0,
          checked6: 0,
          checked7: 0,
          checked8: 0,
          checked9: 0,
          checked10: 0,
          checked11: 0,
          checked12: "",
          checked13: 0,
        };
      }
    },
    getFeedbackLog (id, type) {
      this.axios
        .get("/order/wsCustomerChannelUser/getFeedbackLog?id=" + id)
        .then((res) => {
          if (res.code == 0) {
            this.logs = res.data;
            if (type && this.logs.length >= 10) {
              this.logs = this.logs.slice(0, 9);
            }
          } else {
            this.$message.warning(res.message);
          }
        });
    },
    // 进度提交
    progreeSubmit () {
      let objPro = {
        接通: this.checkedForm.checked1,
        "无法接通/无人接听/拒接": this.checkedForm.checked2,
        接通不是本人: this.checkedForm.checked3,
        电话沟通完添加微信: this.checkedForm.checked4,
        直接搜索手机号添加: this.checkedForm.checked5,
        "有意向/正常走流程": this.checkedForm.checked6,
        添加完不说话: this.checkedForm.checked7,
        添加完拉黑: this.checkedForm.checked8,
        二十岁以下: this.checkedForm.checked9,
        秒杀: this.checkedForm.checked10,
        秒杀金额: this.checkedForm.checked11,
        "空号/停机/暂停服务": this.checkedForm.checked13
      };
      const returnStr = "蓝色字体选项必须填写"
      if (
        this.checkedForm.checked1 == 0 &&
        this.checkedForm.checked2 == 0 &&
        this.checkedForm.checked3 == 0 &&
        this.checkedForm.checked13 == 0
      ) {
        this.$message.warning(returnStr);
        return false;
      }
      // debugger
      if ( this.checkedForm.isConnect == undefined) {
        this.$message.warning(returnStr);
        return false;
      }

      // debugger
      // 接通情况
      if( this.checkedForm.isConnect == "get_through" && this.checkedForm.connectedNotB == undefined) {
        this.$message.warning(returnStr);
        return false;
      }
      // 未接通情况
      if ( this.checkedForm.isConnect == "block_call" && this.checkedForm.connectedNotA == undefined) {
        this.$message.warning(returnStr);
        return false;
      }

      this.axios
        .post("/order/wsCustomerChannelUser/feedback", {
          feedback: objPro,
          id: this.progressId,
          comment: this.checkedForm.checked12,
          // isConnect: this.checkedForm.isConnect,
          qualityLabel:this.checkedForm.isConnect == "get_through" ? "get_through" : "block_call", //  是否接通  "1.get_through"接通 "2.block_call"未接通
          // connectedNot
          connectedNot:this.checkedForm.isConnect == "get_through" ? this.checkedForm.connectedNotB : this.checkedForm.connectedNotA  // 接通情况
        })
        .then((res) => {
          if (res.code == 0) {
            this.$message.success("提交成功");
            this.axiosList();
            this.progress = false;

            this.checkedForm = {
              checked1: 0,
              checked2: 0,
              checked3: 0,
              checked4: 0,
              checked5: 0,
              checked6: 0,
              checked7: 0,
              checked8: 0,
              checked9: 0,
              checked10: 0,
              checked11: 0,
              checked12: "",
              checked13: 0,
            };
          } else {
            this.$message.error(res.message);
          }
        });
    },

    immediUpdate (e) {
      this.$nextTick(() => {
        if (e == null) {
          this.beginTime = "";
          this.endTime = "";
        } else {
          this.$set(this, "date", [e[0], e[1]]);
        }
      });
    },
    //监听弹框的关闭
    handleDialogClose () {
      this.guideId = "";
      this.leadingInLive = false;
    },

    progressClose () {
      this.$confirm("确认关闭？")
        .then((_) => {
          this.progress = false;
          done();
        })
        .catch((_) => { });
    },

    serviceClose () {
      this.$confirm("确认关闭？")
        .then((_) => {
          this.kfShow = false;
          done();
        })
        .catch((_) => { });
    },
    // 模板数据请求 头条，爱奇艺...
    channelSource () {
      this.axios
        .get("/sys/v1/common/by/group?groupId=customer_channel_source_from", {
          headers: {
            isLoading: false,
          },
        })
        .then((res) => {
          // console.log(res);
          if (res.code == 0) {
            let dataList = [];
            for (let i in res.data) {
              if (res.data[i].dictId == "comm") {
                dataList.push(res.data[i]);
              }
            }
            this.channeSel = res.data;
            this.channel = dataList; // res.data.reverse();
          } else {
            this.$message.error(res.message);
          }
        });
    },
    // 模板数据请求
    plFixService () {
      if (this.multipleSelection.length > 0) {
        this.kfShow = true;
        this.moreService = "";
      } else {
        this.$message.error("未选择修改的数据");
      }
    },

    // 多选分配客服
    moreGuideCustomer: _.debounce(function () {
      // 批量修改客服
      let arrayContent = [];
      for (let i in this.multipleSelection) {
        arrayContent.push(this.multipleSelection[i].id);
      }

      this.axios
        .post("/order/wsCustomerChannelUser/batchUpdateAssignor", {
          ids: arrayContent,
          userIds: this.moreService,
        })
        .then((res) => {
          if (res.code == 0) {
            this.$message.success("分配成功");
            this.axiosList();
            this.kfShow = false;
          } else {
            this.$message.error(res.message);
          }
        });
    }, 300),
    //修改渠道与客服
    changeContent: _.debounce(function (row) {
      let inline = "";
      if (row && row.channelId) {
        inline = this.line.find((res) => res.id == row.channelId);
      }
      let name = "";
      if (row && row.assignorId) {
        name = this.customer.find((res) => res.id == row.assignorId);
      }

      let arrayContent = [];

      if (row) {
        arrayContent.push({
          id: row.id,
          channelId: row.channelId,
          channelName: inline.name,
          assignorId: row.assignorId,
          assignorName: name.reallyName,
        });
      } else {
        // 批量修改客服
        for (let i in this.multipleSelection) {
          arrayContent.push({
            id: this.multipleSelection[i].id,
            channelId: this.multipleSelection[i].channelId,
            channelName: this.multipleSelection[i].channelName,
            assignorId: this.moreService,
            assignorName: this.customer.find(
              (res) => res.id == this.moreService
            ).reallyName,
          });
        }
      }

      this.axios
        .post(
          "/order/wsCustomerChannelUser/updateAssignorAndChannel",
          arrayContent,
          {
            headers: {
              isLoading: false,
            },
          }
        )
        .then((res) => {
          if (res.code == 0) {
            if (this.multipleSelection.length > 0) {
              this.axiosList();
              this.kfShow = false;
              //  this.multipleSelection=[];
            }
          } else {
            this.$message.error(res.message);
          }
        });
    }, 300),
    //修改渠道与客服

    //一键分配
    trueDistribution () {
      this.$confirm("确定一键操作分配, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.oneDistribution();
        })
        .catch(() => { });
    },
    oneDistribution: _.debounce(function () {
      this.axios
        .get("/order/v1/customer/channel/one/key/assign", {
          timeout: 12000,
        })
        .then((res) => {
          // console.log(res);
          if (res.code == 0) {
            this.$alert(
              "分配成功的数量: " +
              res.data.successNumber +
              "条, " +
              "分配失败的数量: " +
              res.data.errorNumber +
              "条",
              "提示",
              {
                confirmButtonText: "确定",
              }
            );
            this.currentPage1 = 1;
            this.axiosList();
          } else {
            this.$message.error(res.message);
          }
        });
    }, 500),
    //一键分配
    modeGuide (e) {
      if (e) {
        this.keyvalue = e;
        this.leadingInLive = true;
        this.logFile1 = "";
      }
    },

    orderImportLive (fileObj) {
      let formData = new FormData();
      formData.append("file", fileObj.file);
      this.logFile1 = formData;
    },

    // 导入数据请求
    // 一键导入
    templateMode () {
      this.$refs.tops.clearFiles();
      let config = {
        headers: {
          "Content-Type": "multipart/form-data",
        },
        timeout: 120000,
      };
      this.axios
        .post(
          "/order/wsCustomerChannelUser/one/key/oneKeyImportToWs",
          this.logFile1,
          config
        )
        .then((res) => {
          //   console.log(res);
          if (res.code == 0) {
            this.guideId = ""; //清空模板下拉框
            this.$alert(
              "导入成功的数量: " +
              res.data.successNumber +
              "条, " +
              "导入失败的数量: " +
              res.data.errorNumber +
              "条",
              "提示",
              {
                confirmButtonText: "确定",
              }
            );
            if (res.data.errorUrl) {
              this.downloadlink(res.data.errorUrl);
            }
            if (res.data.errorURI) {
              this.downloadlink(res.data.errorURI);
            }
            this.axiosList();
            this.getUnassignedCount();
          } else {
            this.$message.error(res.message);
          }
        })
        .catch();
    },
    // 部门选择列表
    department () {
      this.axios
        .post(
          "/sys/v1/org/tree/select",
          {
            request: {
              orgName: "",
              orgType: "",
            },
            version: "",
          },
          {
            headers: {
              isLoading: false,
            },
          }
        )
        .then((res) => {
          if (res.code == 0) {
            this.options = res.data;
          } else {
            this.$message.error(res.message);
          }
        });
    },

    reset: _.debounce(function () {
      this.loading = true;
      this.date = "";
      this.assigedate = "";
      this.queryForm = {
        info: "",
        sourceFrom: "",
        assignId: "",
        orgName: "",
        addedWx: "",
        dealDone: "",
      };
      this.currentPage1 = 1;
      this.pageSize = 10;
      this.axiosList("1");
    }, 300),

    searchEvent: _.debounce(function () {
      this.currentPage1 = 1;
      // this.pageSize = 10;
      this.axiosList("1");
    }, 300),

    handleClick (val) {
      this.activeName = val.name;
      this.date = "";
      this.queryForm = {
        info: "",
        sourceFrom: "",
        assignorId: "",
        orgName: [],
      };
      this.currentPage1 = 1;
      this.pageSize = 10;
      this.axiosList();
    },
    toDetailCustomer (row) {
      this.axios
        .get("/order/wsCustomerChannelUser/customerDetails?id=" + row.id)
        .then((res) => {
          if (res.code == 0) {
            this.$router.push({
              name: "customerInformation",
              query: {
                id: res.data.id,
                navName: 4,
              },
            });
          } else {
            this.$message.warning(res.message);
          }
        });
    },
    //*** 放心购导入 ***//
    safeImport: _.debounce(function () {
      // let formData = new FormData();
      // formData.append("file", fileObj.file);
      let config = {
        headers: {
          "Content-Type": "multipart/form-data",
        },
        timeout: 60000,
      };
      this.axios
        .post(
          "/order/v1/customer/channel/rest/assured/import",
          this.logFile1,
          config
        )
        .then((res) => {
          //console.log(res);;
          if (res.code == 0) {
            this.$alert(
              "导入放心购订单 " + res.data.successNumber + " 条",
              "放心购订单",
              {
                confirmButtonText: "确定",
              }
            );
            this.axiosList("1");
          } else {
            this.$message.error(res.message);
          }
        })
        .catch();
    }, 300),
    //*** 放心购导入 ***//
    //*** 百度导入 ***//
    baiduImport: _.debounce(function () {
      // let formData = new FormData();
      // formData.append("file", fileObj.file);
      let config = {
        headers: {
          "Content-Type": "multipart/form-data",
        },
        timeout: 60000,
      };
      this.axios
        .post("/order/v1/customer/channel/baidu/import", this.logFile1, config)
        .then((res) => {
          //console.log(res);
          if (res.code == 0) {
            this.$alert(
              "导入百度订单 " + res.data.successNumber + " 条",
              "百度订单",
              {
                confirmButtonText: "确定",
              }
            );
            this.axiosList("1");
          } else {
            this.$message.error(res.message);
          }
        })
        .catch();
    }, 300),
    //*** 百度导入 ***//
    /*** 广点通导入 ***/
    broadpointImport: _.debounce(function () {
      // let formData = new FormData();
      // formData.append("file", fileObj.file);
      let config = {
        headers: {
          "Content-Type": "multipart/form-data",
        },
        timeout: 60000,
      };
      this.axios
        .post(
          "/order/v1/customer/channel/guangdiantong/import",
          this.logFile1,
          config
        )
        .then((res) => {
          // //console.log(res);;
          if (res.code == 0) {
            this.$alert(
              "导入广点通订单 " + res.data.successNumber + " 条",
              "广点通订单",
              {
                confirmButtonText: "确定",
              }
            );
            this.axiosList("1");
          } else {
            this.$message.error(res.message);
          }
        })
        .catch();
    }, 300),
    /*** 广点通导入 ***/

    /**OPPO**/
    opopImport: _.debounce(function () {
      // let formData = new FormData();
      // formData.append("file", fileObj.file);
      let config = {
        headers: {
          "Content-Type": "multipart/form-data",
        },
        timeout: 60000,
      };
      this.axios
        .post("/order/v1/customer/channel/oppo/import", this.logFile1, config)
        .then((res) => {
          // //console.log(res);;
          if (res.code == 0) {
            this.$alert(
              "导入OPPO订单 " + res.data.successNumber + " 条",
              "OPPO订单",
              {
                confirmButtonText: "确定",
              }
            );
            this.axiosList("1");
          } else {
            this.$message.error(res.message);
          }
        })
        .catch();
    }, 300),
    /**OPPO**/
    /**凤凰订单导入**/
    phoneixImport: _.debounce(function (fileObj) {
      // let formData = new FormData();
      // formData.append("file", fileObj.file);
      let config = {
        headers: {
          "Content-Type": "multipart/form-data",
        },
        timeout: 60000,
      };
      this.axios
        .post(
          "/order/v1/customer/channel/phoenix/import",
          this.logFile1,
          config
        )
        .then((res) => {
          //console.log(res);;
          if (res.code == 0) {
            this.$alert(
              "导入凤凰订单 " + res.data.successNumber + " 条",
              "凤凰订单",
              {
                confirmButtonText: "确定",
              }
            );
            this.axiosList("1");
          } else {
            this.$message.error(res.message);
          }
        })
        .catch();
    }, 300),
    /**凤凰订单导入**/
    /**UC订单导入**/
    uCImport: _.debounce(function (fileObj) {
      // let formData = new FormData();
      // formData.append("file", fileObj.file);
      let config = {
        headers: {
          "Content-Type": "multipart/form-data",
        },
        timeout: 60000,
      };
      this.axios
        .post("/order/v1/customer/channel/uc/import", this.logFile1, config)
        .then((res) => {
          //console.log(res);;
          if (res.code == 0) {
            this.$alert(
              "导入UC订单 " + res.data.successNumber + " 条",
              "UC订单",
              {
                confirmButtonText: "确定",
              }
            );
            this.axiosList("1");
          } else {
            this.$message.error(res.message);
          }
        })
        .catch();
    }, 300),
    /**UC订单导入**/
    /**头条订单导入**/
    headlinesImport: _.debounce(function (fileObj) {
      // let formData = new FormData();
      // formData.append("file", fileObj.file);
      let config = {
        headers: {
          "Content-Type": "multipart/form-data",
        },
        timeout: 60000,
      };
      this.axios
        .post(
          "/order/v1/customer/channel/headline/import",
          this.logFile1,
          config
        )
        .then((res) => {
          //console.log(res);;
          if (res.code == 0) {
            this.$alert(
              "导入头条订单 " + res.data.successNumber + " 条",
              "头条订单",
              {
                confirmButtonText: "确定",
              }
            );
            this.axiosList("1");
          } else {
            this.$message.error(res.message);
          }
        })
        .catch();
    }, 300),
    /**头条订单导入**/
    /**爱奇艺导入**/
    headlinesAiqiyi: _.debounce(function (fileObj) {
      // let formData = new FormData();
      // formData.append("file", fileObj.file);
      let config = {
        headers: {
          "Content-Type": "multipart/form-data",
        },
        timeout: 60000,
      };
      this.axios
        .post("/order/v1/customer/channel/aqy/import", this.logFile1, config)
        .then((res) => {
          //console.log(res);;
          if (res.code == 0) {
            this.$alert(
              "导入爱奇艺订单 " + res.data.successNumber + " 条",
              "爱奇艺订单",
              {
                confirmButtonText: "确定",
              }
            );
            this.axiosList("1");
          } else {
            this.$message.error(res.message);
          }
        })
        .catch();
    }, 300),
    /**爱奇艺导入**/

    /**快手导入**/
    kwaiFu: _.debounce(function (fileObj) {
      // let formData = new FormData();
      // formData.append("file", fileObj.file);
      let config = {
        headers: {
          "Content-Type": "multipart/form-data",
        },
        timeout: 60000,
      };
      this.axios
        .post(
          "/order/v1/customer/channel/quick/worker/import",
          this.logFile1,
          config
        )
        .then((res) => {
          //console.log(res);;
          if (res.code == 0) {
            this.$alert(
              "导入快手订单 " + res.data.successNumber + " 条",
              "快手订单",
              {
                confirmButtonText: "确定",
              }
            );
            this.axiosList("1");
          } else {
            this.$message.error(res.message);
          }
        })
        .catch();
    }, 300),
    /**快手导入**/
    //*** 数据列表 ***//
    axiosList () {
      let beginTime = "";
      let endTime = "";

      if (!this.is_null(this.date)) {
        beginTime = this.date[0] + " 00:00:00";
        endTime = this.date[1] + " 23:59:59";
      }

      let assigedate_begin = "";
      let assigedate_end = "";

      if (!this.is_null(this.assigedate)) {
        assigedate_begin = this.assigedate[0] + " 00:00:00";
        assigedate_end = this.assigedate[1] + " 23:59:59";
      }

      this.axios
        .post("/order/wsCustomerChannelUser/page", {
          assignStatus: this.activeName, //this.queryForm.state, //1已分配 2未分配
          endTime: endTime,
          keyWord: this.queryForm.info,
          pageNo: this.currentPage1,
          pageSize: this.pageSize,
          publicType: "1",
          startTime: beginTime,
          sourceFrom: this.queryForm.sourceFrom, //平台名字
          status: "A",
          assignId: this.queryForm.assignorId,
          assignStartTime: assigedate_begin,
          assignEndTime: assigedate_end,
          assignTeam: this.queryForm.orgName[this.queryForm.orgName.length - 1],
          addedWx: this.queryForm.addedWx,
          dealDone: this.queryForm.dealDone,
          updatedTime: ''
        })
        .then((res) => {
          this.loading = false;
          this.guideId = ""; //清空模板下拉框
          // this.$refs.tops.clearFiles();
          if (res.code == 0) {
            for (let i in res.data.list) {
              res.data.list[i].switchVal = false;
            }
            this.tableData = res.data;

            if (this.multipleSelection) {
              this.$nextTick(() => {
                this.multipleSelection.forEach((v, i) => {
                  this.tableData.list.forEach((_v, _i) => {
                    if (v.id === _v.id) {
                      this.$refs.table.setCheckboxRow(_v, true);
                    }
                  });
                });
              });
            }
          } else {
            this.$message.error(res.message);
          }
        });
    },
    //*** 数据列表 ***//
    //*** 渠道&&客服数据列表 ***//
    channelAxios () {
      this.axios
        .get(
          "/order/comm/customeruser/selectCustomerditch?salesAuthorityId=1",
          {
            headers: {
              isLoading: false,
            },
          }
        )
        .then((res) => {
          // console.log(res);
          if (res.code == 0) {
            this.line = res.data;
          } else {
            this.$message.error(res.message);
          }
        });
    },
    // 分配状态
    allocation () {
      this.axios
        .get("/sys/v1/common/by/group?groupId=assign_status", {
          headers: {
            isLoading: false,
          },
        })
        .then((res) => {
          // console.log('分配状态')
          // //console.log(res);;
          if (res.code == 0) {
            this.allocationList = res.data;
          } else {
            this.$message.error(res.message);
          }
        });
    },
    // 客户下拉框数据
    customerlist () {
      this.axios
        .get("/sys/v1/user/employee/by/sales/authority?salesAuthorityId=1&isQueryDel=0", {
          headers: {
            isLoading: false,
          },
        })
        .then((res) => {
          if (res.code == 0) {
            // let array=[];
            const array = res.data.filter(
              (item) => item.salesAuthorityId === "1"
            );
            this.customer = array;
          } else {
            this.$message.error(res.message);
          }
        });
    },
    //*** 渠道&客服数据列表 ***//

    // 多选
    selectAllEvent ({ checked, records }) {
      this.multipleSelection = records;
    },
    selectChangeEvent ({ checked, records }) {
      this.multipleSelection = records;
      console.log(this.multipleSelection);
    },
    /***分配客户***/
    distribution: _.debounce(function (row) {
      let ids = [];
      if (row) {
        if (row.assignorId && row.channelId) {
          ids.push({
            id: row.id,
            fix: row.switchVal,
          });
        } else {
          this.$message.warning("分配信息填写不完整");
          return;
        }
      } else {
        if (this.multipleSelection.length != 0) {
          for (let i in this.multipleSelection) {
            ids.push({
              id: this.multipleSelection[i].id,
              fix: this.multipleSelection[i].switchVal,
            });
          }
        } else {
          this.$message.warning("未选择需要分配的资源");
          return;
        }
      }

      this.axios
        .post("/order/wsCustomerChannelUser/assignment", ids, {
          headers: {
            isLoading: false,
          },
        })
        .then((res) => {
          if (res.code == 0) {
            if (res.data) {
              if (this.activeName == "3") {
                this.$message.warning("分配失败");
              } else {
                this.$message.warning("分配失败，请在分配失败列表中查看");
              }
            } else {
              this.$message.success("分配成功");
            }
            this.getUnassignedCount();
            this.currentPage1 = 1;
            this.axiosList();
            this.multipleSelection = [];
          } else {
            if (this.activeName == "3") {
              this.$message.error(res.message);
            } else {
              this.$message.error(res.message + ",可在分配失败列表中查看");
            }
          }
        });
    }, 500),
    getUnassignedCount () {
      this.axios
        .get("/order/order/return/taskNumber", { isLoading: false })
        .then((res) => {
          this.$store.dispatch("addOrderCount", res.data);
        });
    },
    //取消分配方法
    unAssign: _.debounce(function () {
      let ids = [];
      if (this.multipleSelection.length != 0) {
        for (let i in this.multipleSelection) {
          ids.push(this.multipleSelection[i].id);
        }
      } else {
        this.$message.warning("未选择需要取消分配的资源");
        return;
      }
      this.axios
        .post("/order/wsCustomerChannelUser/unAssign", ids, {
          headers: {
            isLoading: false,
          },
        })
        .then((res) => {
          if (res.code == 0) {
            this.$message.success("取消分配成功");
            this.currentPage1 = 1;
            this.axiosList();
            this.multipleSelection = [];
            this.getUnassignedCount();
          } else {
            this.$message.error(res.message);
          }
        });
    }, 500),

    /***分配客户***/
    delectEvent: _.debounce(function (row) {
      //   let ids = [];
      //   ids.push(row.id);
      this.$msgbox({
        title: "提示",
        message: "确定删除该数据",
        confirmButtonText: "确定",
        cancelButtonText: "取消",
      })
        .then((res) => {
          this.axios
            .post("/order/wsCustomerChannelUser/delete", [row.id])
            .then((res) => {
              //   console.log(res);
              if (res.code == 0) {
                this.getUnassignedCount();
                this.$message.success("删除成功");
                // let index = this.tableData.list.findIndex(
                //   (item) => item.id == row.id
                // );
                // this.tableData.list.splice(index, 1);
                this.axiosList();
              } else {
                this.$message.warning(res.message);
              }
            });
        })
        .catch(() => { });
    }, 300),
    is_null (content) {
      if (content) {
        return false;
      } else {
        return true;
      }
    },
    tosee (row) {
      this.$router.push({
        name: "jcGuideDetail",
        query: {
          id: row.id,
          name: "guide",
        },
      });
    },
    // 分页
    handleCurrentChange (val) {
      this.currentPage1 = val;
      this.axiosList();
    },
    handleSizeChange (val) {
      this.pageSize = val;
      this.axiosList();
    },
  },
};
</script>

<style scoped lang="scss">
.div1 {
  margin-left: -16px;
  background: url(../../../assets/breadcrumb2.png);
  width: 120px;
  height: 30px;
  text-align: center;
  line-height: 30px;
  color: #2d7edf;
}

.div2 {
  margin-left: -16px;
  background: url(../../../assets/breadcrumb1.png);
  width: 120px;
  height: 30px;
  text-align: center;
  line-height: 30px;
  color: #fff;
}

.nav {
  margin-bottom: 10px;
  /deep/.el-tabs__nav-scroll {
    background: #fff;
  }
  /deep/.el-tabs__item {
    width: 100px;
    text-align: center;
    padding: 0;
  }
}

.btn {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  > div {
    display: flex;
    justify-content: flex-start;
  }
  & ::placeholder {
    color: #fff;
    font-size: 10px;
  }

  /deep/.el-input__inner {
    width: 110px;
    text-align: center;
    height: 30px;
    line-height: 30px;
    background: #409eff;
    color: #fff;
  }
  /deep/.el-input__icon {
    height: 30px;
    line-height: 30px;
    color: #fff;
  }
  .onekey {
    margin-left: 15px;
    width: 100px;
    text-align: center;
    height: 29px;
    line-height: 25px;
    background: #409eff;
    border-radius: 4px;
    img {
      width: 15px;
      height: 15px;
      display: inline-block;
      vertical-align: middle;
      margin-right: 5px;
    }
    span {
      display: inline-block;
      vertical-align: middle;
      font-size: 12px;
      color: #fff;
    }
  }
  .onekey:hover {
    cursor: pointer;
  }
  p {
    font-size: 14px;
  }
}

/deep/.el-tabs__header {
  margin: 0;
}
.header {
  display: flex;
  justify-content: space-between;
  align-items: top;
  span {
    font-size: 15px;
    color: #000;
    padding-bottom: 10px;
  }
  p {
    color: #4168e7;
    font-size: 10px;
  }
  p:hover {
    cursor: pointer;
  }
}

.el-form {
  margin-top: 10px;
}

.inquiry {
  // min-width: 900px;
  background: #fff;
  padding: 10px 10px 0 10px;

  /deep/ .el-input--suffix .el-input__inner {
    height: 30px;
  }
}

.selectDate {
  display: inline-block;
  margin-right: 20px;

  span {
    display: inline-block;
    font-size: 15px;
    margin-right: 15px;
    vertical-align: middle;
  }

  .picker {
    display: inline-block;
    vertical-align: middle;
  }

  /deep/.el-input__inner {
    width: 250px;
    height: 28px;
    line-height: 28px;
  }

  /deep/ .el-date-editor .el-range__icon {
    line-height: 23px;
  }

  /deep/ .el-date-editor .el-range-separator {
    line-height: 23px;
  }

  /deep/.el-date-editor .el-range__close-icon {
    line-height: 22px;
  }
}

/deep/.el-select__input {
  height: 30px !important;
}

.import {
  background: #fff;
  width: 100%;
  height: 40px;

  li {
    float: left;
    margin-right: 10px;
  }
}

.table {
  margin: 10px 0;
  // margin-bottom: 40px;

  /deep/.el-select .el-input .el-select__caret {
    color: #000;
    font-size: 14px;
    cursor: pointer;
  }

  /deep/.el-input__icon {
    height: 32px;
    line-height: 32px;
  }

  /deep/.el-input--suffix .el-input__inner {
    width: 140px;
    height: 32px;
    color: #000;
  }
  /deep/ .el-button {
    padding: 10px 13px;
  }
}

/deep/.el-table thead {
  color: #2d7edf;
  text-align: center;

  .cell {
    text-align: center;
  }
}

.operation {
  display: inline-block;
  padding: 0 3px;
  color: #2d7ddf;

  img {
    width: 20px;
    height: 20px;
  }
}
.operation:hover {
  cursor: pointer;
}
.delect {
  color: #ff5656;
}

/deep/.el-table td,
.el-table th {
  text-align: center;
}

.page {
  // margin: 10px 0;
  text-align: right;
  width: 100%;
  background: #f5f5f5;
  padding-right: 20px;
  position: fixed;
  bottom: 0px;
  right: 0px;
  z-index: 1000;

  span {
    font-size: 14px;
    color: #666;
    display: inline-block;
    margin-left: 10px;
  }

  /deep/.el-input--suffix .el-input__inner {
    height: 30px;
  }

  .el-pagination {
    display: inline-block;
    vertical-align: middle;
  }
}
/deep/.el-dialog__header {
  background: #409eff;
  padding: 10px 20px 10px;
  .el-dialog__title {
    color: #fff;
  }
}
/deep/.el-dialog__headerbtn {
  top: 15px;
}

/deep/.el-dialog__headerbtn .el-dialog__close {
  color: #fff;
}
.exisit {
  //   width: 44px;
  height: 18px;
  line-height: 18px;
  //   background: #fff4f4;
  border-radius: 3px;
  //   border: 1px solid #ff5656;
  text-align: center;
  font-size: 10px;
  color: #ff5656;
  //   margin-left: 5px;
}

/deep/.el-checkbox {
  margin-bottom: 12px;
}
.checkbox {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  margin-left: 10px;
  display: inline-block;
  span {
    display: inline-block;
    margin: 0 10px;
    vertical-align: middle;
  }
  /deep/.el-input {
    width: 150px;
  }
  /deep/.el-textarea {
    width: 200px;
    display: inline-block;
    vertical-align: middle;
  }
}
.footer {
  margin-top: 20px;
  display: flex;
  justify-content: flex-end;
}

.haveTo {
  color: #3196ff;
}
</style>
